function admin() {
    window.location.href = base_url+"/admin";
}

function login(){

    layer.open({
        type: 1
        ,title: false //不显示标题栏
        ,closeBtn: false
        ,area: '300px;'
        ,shade: 0.8
        ,id: 'LAY_layuipro' //设定一个id，防止重复弹出
        ,btn: ['关闭']
        ,btnAlign: 'c'
        ,moveType: 1 //拖拽模式，0或者1
        ,content: '<div style="padding: 50px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;">' +
            '<span>用户名:<input id="us" class="layui-input" type="text"/></span><br/>'+
            '<span>密码:<input id="ps" class="layui-input" type="password"/></span><br/>' +
            '<br/><button type="button" onclick="loginAction()" class="layui-btn layui-btn-normal">登录</button>'+

            '</div></center>'
        ,success: function(layero){

        }
    });
}

function loginAction(){

    //获取输入的选框信息
    var us = $("#us").val();
    var ps = $("#ps").val();

    if(us==undefined || us==null || us==""){
        layer.msg("请输入用户名");
       return false;
    }

    if(ps==undefined || ps==null || ps==""){
        layer.msg("请输入密码");
        return false;
    }
    //调用ajax
    var settings = {
        "url": base_url+"/api/base?action=login&userName="+us+"&passWord="+ps,
        "method": "GET",
        "timeout": 0,
    };

    $(function () {
        debugger
        $.ajax(settings).done(function (response) {
            console.log(response);
            if(response.code == 403){
                layer.alert(response.message);
            }else if(response.code == 200){
                layer.alert(response.message);
                setTimeout(function () {
                    location.href = base_url+"/user/"+response.data.id;
                },1000)
            }else{
                layer.alert("服务器开小差...");
            }

        });
    })
}